File: /home/sioberen/www/cache/includes/purchase_panel_complete.php
<div class="w-280px">
<div class="panel_buy mgnB20" id="cart">
<div class="price_choise price_group selected_price">
<?php if (isset($data['price']['new'])): ?>
New <span class="text-price-detail price-buy"><?php echo $data['price']['new']; ?></span>
<?php elseif (isset($data['price']['used'])): ?>
Used <span class="text-price-detail price-buy"><?php echo $data['price']['used']; ?></span>
<?php endif; ?>
</div>
<input type="hidden" name="amount_max" value="1" class="amount_max">
<form class="cart add-cart" method="post" action="<?php echo htmlspecialchars($data['random_link']); ?>">
<input type="hidden" name="rem" value="<?php echo $data['management_number']; ?>000">
<input type="hidden" name="branch_number" value="0001">
<input type="hidden" name="return_url" value="<?php echo htmlspecialchars(basename($request_uri)); ?>">
<input type="hidden" name="product_name" value="<?php echo htmlspecialchars($data['title']); ?>">
<input type="hidden" name="product_image" value="<?php echo isset($data['images'][0]) ? $data['images'][0] : $data['default_image']; ?>">
<input type="hidden" name="product_price" value="<?php echo isset($data['price']['new']) ? $data['price']['new'] : $data['price']['used']; ?>">
<input type="hidden" name="product_url" value="<?php echo buildProductUrl($data['management_number'], $data['title']); ?>">
<input type="hidden" name="product_id" value="<?php echo $data['management_number']; ?>">
<input type="hidden" name="product_category" value="<?php echo htmlspecialchars(end($data['categories'])); ?>">
<input type="hidden" name="product_brand" value="<?php echo htmlspecialchars($data['brand']); ?>">
<input type="hidden" name="product_currency" value="<?php echo $data['currency']; ?>">
<div class="product_amounts d-flex justify-content-start align-items-center mb-3">
<span class="padR12">quantity</span>
<div class="border rounded bg-white">
<select id="quantity_selection" class="bg-white border-0 form-control-sm">
<option value="1">1 point</option>
</select>
</div>
</div>
<input type="hidden" name="amount" value="1" id="amount">
<div class="mgnT12">
<button type="submit" class="btn btn-warning btn-lg btn-block btn_buy cart1" id="btn_add_cart">
<img src="https://cdn.suruga-ya.jp/pics/common/pc/add_cart.svg" alt="cart icon" class="mgnR8" width="26px" style="vertical-align: middle;">
Add to Cart
</button>
<button type="button" class="btn btn-light btn-lg btn-block btn_wishlist mgnT12" onclick="addToFavorite(<?php echo $data['management_number']; ?>)">
<img src="https://cdn.suruga-ya.jp/pics/common/pc/star_whishlist.svg" alt="favorite icon" class="mgnR8" width="22px" style="vertical-align: text-bottom;">
Add to favorites list
</button>
</div>
</form>
</div>
<!-- ����ȷ��ģ̬�� -->
<div class="modal fade" id="buyConfirmModal" tabindex="-1" aria-labelledby="buyConfirmModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="buyConfirmModalLabel">Confirm Purchase</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="buy-confirm-content">
<div class="product-summary">
<img src="<?php echo isset($data['images'][0]) ? $data['images'][0] : $data['default_image']; ?>" alt="<?php echo htmlspecialchars($data['title']); ?>" class="product-thumb">
<div class="product-info">
<h6><?php echo htmlspecialchars($data['title']); ?></h6>
<p class="price"><?php echo isset($data['price']['new']) ? $data['price']['new'] : $data['price']['used']; ?></p>
<p class="quantity">Quantity: <span id="confirm-quantity">1</span></p>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-red" id="confirmPurchase">Confirm Purchase</button>
</div>
</div>
</div>
</div>
<!-- �ղ�ȷ��ģ̬�� -->
<div class="modal fade" id="favoriteConfirmModal" tabindex="-1" aria-labelledby="favoriteConfirmModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="favoriteConfirmModalLabel">Add to Favorites</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>This item has been added to your favorites.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a href="<?php echo htmlspecialchars(get_next_random_link($data)); ?>" class="btn btn-primary">View Favorites</a>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// ������ύ����
document.querySelector('.add-cart').addEventListener('submit', function(e) {
e.preventDefault();
var formData = new FormData(this);
var quantity = formData.get('amount');
// ����ȷ��ģ̬���е�����
document.getElementById('confirm-quantity').textContent = quantity;
// ��ʾ����ȷ��ģ̬��
$('#buyConfirmModal').modal('show');
});
// ȷ�Ϲ���ť����
document.getElementById('confirmPurchase').addEventListener('click', function() {
var form = document.querySelector('.add-cart');
var formData = new FormData(form);
// ����GA�¼�
var price = parseFloat(formData.get('product_price').replace(/[^0-9.-]+/g, ''));
var quantity = parseInt(formData.get('amount'));
if (typeof addToCart === 'function') {
addToCart(price, quantity);
}
// �ύ��
form.submit();
});
// �������ص�amount�ֶ�
document.getElementById('quantity_selection').addEventListener('change', function() {
document.getElementById('amount').value = this.value;
});
});
function addToFavorite(productId) {
// ����������AJAX��������
// ����ֻ����ʾȷ��ģ̬��
$('#favoriteConfirmModal').modal('show');
// ����е�¼�û������Է�����������
// fetch('/api/favorites/add', {
// method: 'POST',
// headers: {'Content-Type': 'application/json'},
// body: JSON.stringify({product_id: productId})
// });
}
function shareProduct() {
if (navigator.share) {
navigator.share({
title: '<?php echo addslashes($data['title']); ?>',
text: '<?php echo addslashes($data['title']); ?>',
url: window.location.href
});
} else {
// �������ӵ�������
navigator.clipboard.writeText(window.location.href).then(function() {
alert('Product link copied to clipboard!');
});
}
}
</script>
<style>
.w-280px {
width: 280px;
}
.panel_buy {
background: #fff;
border: 1px solid #ddd;
border-radius: 5px;
padding: 20px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.price_choise {
font-size: 18px;
font-weight: bold;
margin-bottom: 15px;
padding: 10px;
background: #f8f9fa;
border-radius: 3px;
}
.text-price-detail {
color: #dc3545;
font-size: 20px;
}
.product_amounts {
font-size: 14px;
}
.padR12 {
padding-right: 12px;
}
.mgnT12 {
margin-top: 12px !important;
}
.btn_buy.cart1 {
background: linear-gradient(to bottom,#faa821,#f7941d);
border-color: #f08f0c;
color: white;
font-weight: bold;
text-shadow: 0 -1px 0 rgba(0,0,0,.2);
}
.btn_buy.cart1:hover {
background: #f7941d;
border-color: #f08f0c;
}
.btn_wishlist, .btn_share {
background: #f8f8f8;
border-color: #ccc;
font-weight: bold;
color: #333;
}
.btn_wishlist:hover, .btn_share:hover {
background-color: #e6e6e6;
border-color: #adadad;
}
.product-summary {
display: flex;
align-items: center;
gap: 15px;
}
.product-thumb {
width: 80px;
height: 80px;
object-fit: cover;
border-radius: 5px;
}
.product-info h6 {
margin: 0 0 10px 0;
font-size: 14px;
}
.product-info .price {
color: #dc3545;
font-weight: bold;
margin: 0;
}
.product-info .quantity {
margin: 5px 0 0 0;
font-size: 14px;
}
</style>